//
//  ZHCycleScrollView.h
//  XZYUser
//
//  Created by chun.chen on 2020/4/13.
//  Copyright © 2020 Zhihan. All rights reserved.
//  banner滚动广告

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@class ZHCycleScrollView;
@protocol ZHCycleScrollViewDelegate <NSObject>

@optional

/// 自定义配置每个cell
/// @param cycleScrollView cycleScrollView description
/// @param indexPath collectionview的路径 非实际下标
/// @param index 实际显示下标
- (__kindof UICollectionViewCell *)cycleScrollView:(ZHCycleScrollView *)cycleScrollView cellForItemAtIndexPath:(NSIndexPath *)indexPath atIndex:(NSInteger)index;
/// 点击图片回调
/// @param cycleScrollView cycleScrollView description
/// @param index 位置下标
- (void)cycleScrollView:(ZHCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index;
/// 图片滚动回调
/// @param cycleScrollView cycleScrollView description
/// @param index 位置下标
- (void)cycleScrollView:(ZHCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index;

@end

@interface ZHCycleScrollView : UIView
/// 网络图片 url string 数组
@property (nonatomic, strong) NSArray *imageURLStringsGroup;
///自动滚动间隔时间,默认5s
@property (nonatomic, assign) CGFloat autoScrollTimeInterval;
///是否无限循环,默认Yes
@property (nonatomic, assign) BOOL infiniteLoop;
///是否自动滚动,默认Yes
@property (nonatomic, assign) BOOL autoScroll;
///委托
@property (nonatomic, weak) id<ZHCycleScrollViewDelegate> delegate;
/// block方式监听点击
@property (nonatomic, copy) void (^ clickItemOperationBlock)(NSInteger currentIndex);
/// block方式监听滚动
@property (nonatomic, copy) void (^ itemDidScrollOperationBlock)(NSInteger currentIndex);
/// 占位图，用于网络未加载到图片时
@property (nonatomic, strong, nullable) UIImage *placeholderImage;
///*是否显示分页控件
@property (nonatomic, assign) BOOL showPageControl;
/// 是否在只有一张图时隐藏pagecontrol，默认为YES
@property (nonatomic) BOOL hidesForSinglePage;
/// 分页控件距离轮播图的底部间距（在默认间距基础上）的偏移量
@property (nonatomic, assign) CGFloat pageControlBottomOffset;
/// 当前分页控件小圆标颜色
@property (nonatomic, strong) UIColor *currentPageDotColor;
/// 其他分页控件小圆标颜色
@property (nonatomic, strong) UIColor *pageDotColor;

/// 初始轮播图（推荐使用）
/// @param frame frame description
/// @param delegate delegate description
/// @param placeholderImage 图片展位图
+ (instancetype)cycleScrollViewWithFrame:(CGRect)frame delegate:(id<ZHCycleScrollViewDelegate>)delegate placeholderImage:(nullable UIImage *)placeholderImage;

/// 初始轮播图
/// @param frame frame description
/// @param imageURLStringsGroup 图片url
+ (instancetype)cycleScrollViewWithFrame:(CGRect)frame imageURLStringsGroup:(NSArray *)imageURLStringsGroup;

/// 手动控制滚动到哪一个index
/// @param index index description
- (void)makeScrollViewScrollToIndex:(NSInteger)index;

/// 解决viewWillAppear时出现时轮播图卡在一半的问题，在控制器viewWillAppear时调用此方法
- (void)adjustWhenControllerViewWillAppera;
/// 滚动手势禁用
- (void)disableScrollGesture;
///计时器开始工作
- (void)startTimerAction;
///停止计时器
- (void)stopTimer;


/// UICollectionView 注册cell
/// @param cellClass cellClass description
/// @param identifier identifier description
- (void)registerClass:(nullable Class)cellClass forCellWithReuseIdentifier:(NSString *)identifier;

/// 返回对应的cell
/// @param identifier identifier description
/// @param indexPath indexPath description
- (__kindof UICollectionViewCell *)dequeueReusableCellWithReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;
@end

NS_ASSUME_NONNULL_END
